@extends('layouts.default') @section('main')
    <link rel="stylesheet" href="/css/uniform.css" />
    <link rel="stylesheet" href="/css/select2.css" />

    <div id="content">
        <div id="content-header">
            <div id="breadcrumb"> <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a> <a href="#" class="current">项目管理</a> </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span12">
                    @if(in_array('add',$actions))<a href="{{url('project/create')}}"><button class="btn">新增</button></a>@endif
                        <table>
                            <tr>
                                <form action="{{url('project/search')}}" method="post">

                                    <th>
                                        <label >项目名 :</label>
                                    </th>
                                    <th>
                                        <div class="controls">
                                            <input type="text" class="span11" name="subject" value="" placeholder="项目名" style="width:120px" />
                                        </div>
                                    </th>

                                    <th>
                                        <label >发起人 :</label>
                                    </th>
                                    <th>
                                        <div class="controls">
                                            <input type="text" class="span11" name="create_user" value="" placeholder="发起人" style="width:80px" />
                                        </div>
                                    </th>
                                    <th>
                                        <label >状态 :</label>
                                    </th>
                                    <th>
                                        <div class="controls">
                                            <select  name="pStatus" class="span11" >
                                                <option value="">请选择审核状态</option>
                                                <option value="1">审核通过</option>
                                                <option value="0">审核中</option>
                                                <option value="2">审核不通过</option>
                                                <option value="-1">禁用</option>
                                                <option value="3">融资成功</option>
                                            </select>
                                        </div>
                                    </th>
                                    <th>
                                        <label >类型 :</label>
                                    </th>
                                    <th>
                                        <div class="controls">
                                            <select  name="type" class="span11" >
                                                <option value="">请选择类型</option>
                                                <option value="chuangye">创业</option>
                                                <option value="newthree">新三板</option>
                                                <option value="ppp">ppp</option>
                                            </select>
                                        </div>
                                    </th>
                                    <th>
                                        <label >是否路演 :</label>
                                    </th>
                                    <th>
                                        <div class="controls">
                                            <select  name="roadshow" class="span11" >
                                                <option value="">是否路演</option>
                                                <option value="1">已路演</option>
                                                <option value="0">未路演</option>
                                            </select>
                                        </div>
                                    </th>
                                    <th>
                                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                        <div class="controls">
                                            <button type="submit" class="btn btn-info">查询</button>
                                        </div>
                                    </th>
                                </form>
                                <th>
                                    <label >批量审核 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <select  id="status" name="status" class="span11" >
                                            <option value="">请选择审核状态</option>
                                            <option value="1">审核通过</option>
                                            <option value="0">审核中</option>
                                            <option value="2">审核不通过</option>
                                            <option value="-1">禁用</option>
                                        </select>
                                    </div>
                                </th>
                                <th>
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <div class="controls">
                                        <button type="button" id="mass" class="btn btn-info">批量审核</button>
                                    </div>
                                </th>
                            </tr>
                        </table>

                        <div class="widget-box">
                            <div class="widget-title">
                            <span class="icon">
                                <input type="checkbox" id="title-checkbox" name="title-checkbox" />
                            </span>
                                <h5>项目管理</h5>
                            </div>
                            <div class="widget-content nopadding">
                                <table class="table table-bordered table-striped with-check" id="table">
                                    <thead>
                                    <tr>
                                        <th><i class="icon-resize-vertical"></i></th>
                                        {{--<th>项目ID</th>--}}
                                        <th>项目名</th>
                                        <th>项目发起者</th>
                                        <th>项目阶段</th>
                                        <th>所在城市</th>
                                        <th>创建时间</th>
                                        <th>访问数</th>
                                        <th>项目详情</th>
                                        <th>项目跟踪人</th>
                                        <th>类型</th>
                                        <th>评论管理</th>

                                        <th>状态</th>
                                        <th>是否推荐</th>
                                        <th>是否向投资人公开</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    @foreach($projects as $key => $project)
                                        <tr>
                                            <td><input type="checkbox" value="{{$project->id}}" /></td>
                                            {{--<td>{{ $project->id }}</td>--}}
                                            <td title="{{ $project->subject }}">{{ cut_str($project->subject,14) }}</td>
                                            <td>@if ($project->user) {{$project->user->nickname?$project->user->nickname:$project->user->realname}} @endif</td>
                                            <td>@if($project->project_period=='chuchuang')初创期@elseif($project->project_period=='chengzhang')成长期@elseif($project->project_period=='chengshu')成熟期@elseif($project->project_period=='zhongzi')种子期 @elseif($project->newthree_period=='niguapai')拟挂牌 @elseif($project->newthree_period=='yiguapai')已挂牌@endif</td>
                                            <td>{{ $project->city->name or '' }}</td>
                                            <td><?php echo date('Y-m-d',strtotime($project->created_at)); ?></td>
                                            <td>{{ $project->views }}</td>
                                            <td><a href="{{ url('project/info?id='.$project->id) }}">点击查看</a></td>
                                            <td>{{ $project->track_person }}</td>
                                            <td>@if($project->type=='chuangye') 创业 @elseif($project->type=='newthree') 新三板@elseif($project->type=='ppp') ppp @endif</td>
                                            <td><a href="{{ url('projectcomment/index?id='.$project->id) }}">点击管理</a></td>
                                            <td>@if($project->status == 1)<i class="icon-ok"></i>@elseif($project->status == 0)<i class="icon-question-sign"></i>@elseif($project->status == 2)<i class="icon-ban-circle"></i>@elseif($project->status == -1)<i class="icon-remove-sign"></i> @elseif($project->status == 3)<i class="icon-thumbs-up"></i>@endif</td>
                                            <td>@if($project->recommend == 1)<i class="icon-ok"></i>@else<i class="icon-question-sign"></i>@endif</td>
                                            <td>@if($project->open_to_investor == 1)<i class="icon-ok"></i>@else<i class="icon-ban-circle"></i>@endif</td>
                                            <td class="center">
                                                @if(in_array('edit',$actions))<a data-original-title="编辑" id="edit" class="tip" href="{{url('project/edit?id='.$project->id)}}"><i class="icon-pencil"></i></a>@endif
                                                {{--@if(in_array('delete',$actions))<a data-original-title="删除" data-toggle="modal" id="delete" class="tip project_delete" href="#myAlert" p_id="{{$project->id}}"><i class="icon-remove"></i></a> @endif--}}
                                            </td>
                                        </tr>
                                    @endforeach
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    <?php echo $projects->appends(Input::all())->render();?>
                </div>
            </div>
        </div>
    </div>
    <script src="/js/matrix.tables.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>

    <script>


        $(".project_delete").click(function(){
            var p_id = $(this).attr("p_id");
            $("input[name='pid']").val(p_id);
        });
        $(".btn-primary").click(function(){
            var p_id = $("input[name='pid']").val();
            if(p_id == 0){
                alert('参数异常');
                return;
            }

            ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                }
            });
        });


        function allchk(){
            var chknum = $("#table :checkbox").size();//选项总个数
            var chk = 0;
            $("#table :checkbox").each(function () {
                if($(this).prop("checked")==true){
                    chk++;
                }
            });
            if(chknum==chk){
                $("#title-checkbox").prop("checked",true);
            }else{
                $("#title-checkbox").prop("checked",false);
            }
        }

        $("#title-checkbox").click(function(){
            if(this.checked){
                $("#table :checkbox").prop("checked", true);
            }else{
                $("#table :checkbox").prop("checked", false);
            }
        });

        $("#table :checkbox").click(function(){
            allchk();
        });

        $("#mass").click(function(){
            var valArr = new Array();

            $("#table :checkbox").each(function(i){
                if($(this).prop('checked')==true){
                    valArr[i] = $(this).val();
                }
            });
            var vals = valArr.join(',');
            var status = ($('#status').val());
            ajaxRequest({ project: vals, status: status },"{{url('project/mass-audit')}}",function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                }
            });
        });

    </script>
@stop
